import Vue from 'vue';
import App from './App.vue';
import router from './router/index.js';
import axios from 'axios';
import Vuex from 'vuex';
import VCharts from 'v-charts'
import {substr} from './filters';
// import './assets/style/reset.css';
import './assets/style/movie-list.css';
//注册图表组件
Vue.use(VCharts);
//全局导入vant组件
// import Vant from 'vant';
// import 'vant/lib/vant-css/index.css';
// Vue.use(Vant);

Vue.use(Vuex);

const state={
    pageTitle:'首页'
}
const mutations={
   changePageTitle:(state,params)=>{
      state.pageTitle=params;
   }
}
const store=new Vuex.Store({
  state,
  mutations
});

Vue.prototype.$http=axios

// axios.defaults.baseURL = "https://api.douban.com/v2";



router.beforeEach((to,from,next)=>{
  if(to.meta.title){
      document.title=to.meta.title+' | 豆瓣大电影';
      //修改pageTitle
      store.commit('changePageTitle',to.meta.title);
  }
  next();
});

var vm=new Vue({
  el: '#app',
  router,
  store,
  filters:{
    limit(params){
      // return params.substring(0,2)+'...';
      return 'aaa';
    }
  },
  render: h => h(App)
  // components: { App },
  // template:'<App/>',
});
